package com.tidc.consumer8001.service.impl;

import com.tidc.api.controller.UserManagerApi;
import com.tidc.api.pojo.UserOV;
import com.tidc.api.pojo.user.User;
import com.tidc.consumer8001.service.UserManagerService;
import com.tidc.consumer8001.utils.UserInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import java.util.LinkedHashMap;
import java.util.List;

/**
 * @ClassNmae UserManagerServiceImpl
 * @Description TODO
 * @Author 冯涛滔
 **/
@Service
public class UserManagerServiceImpl implements UserManagerService {
	@Autowired
	private UserManagerApi userManagerApi;
	@Autowired
	private UserInfo userInfo;
	public UserOV register(User user){
		return userManagerApi.register(user);
	}

	@Override
	public UserOV switchTeacher(User teacher,HttpServletRequest req) {
		User teacher2 = (User) userInfo.userInfo(req);
		teacher.getUserDetail().setSchool_id(teacher2.getUserDetail().getSchool_id());
		return userManagerApi.switchTeacher(teacher);
	}

	@Override
	public UserOV userInfo(String email) {
		return userManagerApi.userInfo(email);
	}

	public UserOV<List<User>> listSchoolStudent(HttpServletRequest req){
		User school = (User) userInfo.userInfo(req);
		return userManagerApi.listSchoolStudent(school.getId());
	}

	@Override
	public UserOV<List<String>> listStudentEmail(List<Integer> list) {
		return userManagerApi.listStudentEmail(list);
	}

	@Override
	public UserOV<User> getStudent(String email) {
		return userManagerApi.getStudent(email);
	}

}
